﻿using System;
using System.IO;

namespace Samurai.Crawler
{
    /// <summary>
    /// Event arguments for the DirectoryEvent
    /// </summary>
    public class DirectoryEventArgs : EventArgs
    {
        #region Constructors

        /// <summary>
        /// Block the default constructor.
        /// </summary>
        private DirectoryEventArgs() { }

        /// <summary>
        /// Initializes a new instance of the <see cref="DirectoryEventArgs"/> class.
        /// </summary>
        /// <param name="directory"><see cref="DirectoryInfo"/> object for the current path.</param>
        /// <param name="action">The action.</param>
        internal DirectoryEventArgs(DirectoryInfo directory, ScanDirectoryAction action)
        {
            if (directory == null) throw new ArgumentNullException("directory");

            // Get File information 
            _directoryInfo = directory;
            _action = action;
        }

        #endregion

        #region Properties

        private DirectoryInfo _directoryInfo;
        private ScanDirectoryAction _action;
        private bool _cancel;

        /// <summary>
        /// Gets the current directory information.
        /// </summary>
        /// <value>The <see cref="DirectoryInfo"/> object for the current directory.</value>
        public DirectoryInfo Info
        {
            get { return _directoryInfo; }
        }

        /// <summary>
        /// Gets the current directory action.
        /// </summary>
        /// <value>The <see cref="ScanDirectoryAction"/> action value.</value>
        public ScanDirectoryAction Action
        {
            get { return _action; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether to cancel the directory scan.
        /// </summary>
        /// <value>
        /// <see langword="true"/> if the scan must be cancelled; otherwise, <see langword="false"/>.
        /// </value>
        public bool Cancel
        {
            get { return _cancel; }
            set { _cancel = value; }
        }

        #endregion
    }
}